[FEAT] Add Mistral embedding adapter (mistral-embed)#2158
[FEAT] Add Mistral embedding adapter (mistral-embed)#2158chandrasekharan-zipstack merged 2 commits into
Conversation
Mistral was a first-class LLM adapter but had no embedding adapter, despite shipping a real, popular embedding model (mistral-embed). This adds a native Mistral embedding adapter that routes through LiteLLM's `mistral/` provider, so cost calculation works out of the box. - MistralEmbeddingParameters in base1.py (idempotent `mistral/` prefix, required-model validation) - MistralEmbeddingAdapter + UI JSON schema, reusing the existing logo - Registered in embedding1/__init__.py - 28 unit tests mirroring the Gemini embedding coverage Closes Zipstack#2157 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Summary by CodeRabbit
WalkthroughAdds a new Mistral embedding adapter to the Unstract SDK, including a ChangesMistral Embedding Adapter
Estimated code review effort: 2 (Simple) | ~15 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| unstract/sdk1/src/unstract/sdk1/adapters/base1.py | Adds MistralEmbeddingParameters, directly mirroring GeminiEmbeddingParameters — same api_key + embed_batch_size fields, same idempotent prefix logic, same mutation-safe validate() pattern using a dict copy. |
| unstract/sdk1/src/unstract/sdk1/adapters/embedding1/mistral.py | New MistralEmbeddingAdapter implementing the full BaseAdapter contract; correctly reuses the LLM Mistral icon and returns AdapterTypes.EMBEDDING. |
| unstract/sdk1/src/unstract/sdk1/adapters/embedding1/static/mistral.json | New JSON schema for the Mistral embedding UI form; layout and field constraints are identical to gemini.json, with appropriate Mistral-specific defaults and descriptions. |
| unstract/sdk1/src/unstract/sdk1/adapters/embedding1/init.py | Adds MistralEmbeddingAdapter to both the import list and all; alphabetical ordering is maintained. |
| unstract/sdk1/tests/test_mistral_embedding.py | 28 tests covering registration, schema shape, prefix idempotency, mutation safety, and error-path validation; mirrors the Gemini embedding test suite for consistency. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant UI as User / UI Form
participant Schema as mistral.json (JSON Schema)
participant Adapter as MistralEmbeddingAdapter
participant Params as MistralEmbeddingParameters
participant LiteLLM as LiteLLM (mistral/ provider)
UI->>Schema: Render config form
Schema-->>UI: adapter_name, model, api_key, timeout fields
UI->>Adapter: validate(adapter_metadata)
Adapter->>Params: validate_model(metadata_copy)
Params-->>Adapter: mistral/model prefix added idempotently
Adapter->>Params: MistralEmbeddingParameters model_dump()
Params-->>Adapter: validated dict
Adapter-->>UI: validated adapter config
Adapter->>LiteLLM: embedding call
LiteLLM-->>Adapter: embedding vectors + cost via mistral provider
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant UI as User / UI Form
participant Schema as mistral.json (JSON Schema)
participant Adapter as MistralEmbeddingAdapter
participant Params as MistralEmbeddingParameters
participant LiteLLM as LiteLLM (mistral/ provider)
UI->>Schema: Render config form
Schema-->>UI: adapter_name, model, api_key, timeout fields
UI->>Adapter: validate(adapter_metadata)
Adapter->>Params: validate_model(metadata_copy)
Params-->>Adapter: mistral/model prefix added idempotently
Adapter->>Params: MistralEmbeddingParameters model_dump()
Params-->>Adapter: validated dict
Adapter-->>UI: validated adapter config
Adapter->>LiteLLM: embedding call
LiteLLM-->>Adapter: embedding vectors + cost via mistral provider
Reviews (2): Last reviewed commit: "Merge branch 'main' into feat/mistral-em..." | Re-trigger Greptile
|



Mistral was a first-class LLM adapter but had no embedding adapter, despite shipping a real, popular embedding model (mistral-embed). This adds a native Mistral embedding adapter that routes through LiteLLM's
mistral/provider, so cost calculation works out of the box.mistral/prefix, required-model validation)Closes #2157
What
Adds a native Mistral embedding adapter (
mistral-embed) tounstract/sdk1. Mistral was already a first-class LLM adapter but had no embedding counterpart.MistralEmbeddingParametersinbase1.py(idempotentmistral/prefix, required-model validation)MistralEmbeddingAdapter+ UI JSON schema (embedding1/static/mistral.json), reusing the existing Mistral logoRegistered in
embedding1/__init__.py28 unit tests mirroring the Gemini embedding coverage
Why
mistral, but the 9 embedding adapters did not, despitemistral-embedbeing a real, popular model.mistral/provider means cost calculation works out of the box (litellm_provider: "mistral"matchesget_provider()).How
MistralEmbeddingParameters(BaseEmbeddingParameters)validates the requiredmodeland prepends themistral/prefix idempotently (won't double-prefix an already-prefixed model).MistralEmbeddingAdapterfollows the existing embedding-adapter contract (get_id/get_provider/get_adapter_type/etc.), returnsAdapterTypes.EMBEDDING, and is auto-discovered byregister_adapters().mistral/mistral-embed→litellm_provider: "mistral",mode: "embedding", 8192 max tokens.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
mistral) already exists as an LLM provider, so cost-calculation behavior for existing adapters is untouched.Database Migrations
Env Config
Relevant Docs
mistral-embed(auto-prefixed tomistral/mistral-embed)Related Issues or PRs
Dependencies Versions
mistral/provider.Notes on Testing
tests/test_mistral_embedding.py— 28 tests covering registration, ID format, provider name, JSON schema (required fields, defaults, password format), model-prefix idempotency, input-mutation safety, and validation errors (empty/whitespace/None/missing model, missing API key).ruff check→ all passed;ruff format --check→ all files formatted.Screenshots
N/A — no custom UI; the adapter renders through the standard auto-generated config form.
Checklist
I have read and understood the Contribution Guidelines.